<template>
	<view class="main">

		<view class="list" v-for="(i,o) in list" :key="o">
			<view class="list-item-r">
				<view class="list-item-r-n">{{i.name}}<text>{{i.position}}</text></view>
				<view class="list-item-r-g">公司：{{i.company}}</view>
				<view class="list-item-r-m">联系方式：{{i.mobile || '-'}}</view>
			</view>
		</view>

		<view class="addUser" v-if="isAdministrators == 1" @click="addUser">添加/编辑管理员</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemId: '',
				list: [],
				selects: [],
				isAdministrators: '',
			}
		},
		onLoad(e) {
			this.itemId = e.id
			this.isAdministrators = e.isAdministrators
		},
		onShow() {
			this.getList()
		},
		methods: {
			addUser() {
				uni.navigateTo({
					url: '/pagesBusiness/rvManagement/rvAddUser?id=' + this.itemId + '&selects=' + this.selects
				})
			},
			async getList() {
				let res = await this.$api.getUserList({
					rvId: this.itemId
				})
				this.list = res.result
				if (this.list) {
					this.list.map(i => {
						this.selects.push(i.openid)
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		width: 700rpx;
		margin: 20rpx auto;
		position: relative;
		padding-bottom: 200rpx;

		.list {

			.list-item-r {
				background: linear-gradient(45deg, #276aee, #276aee99);
				padding: 20rpx;
				border-radius: 12rpx;
				margin: 20rpx 0;
				position: relative;
				color: #fff;

				.list-item-r-n {
					font-weight: bold;
					font-size: 33rpx;

					text {
						font-size: 28rpx;
						display: inline-block;
						margin-left: 20rpx;
					}
				}

				.list-item-r-g {
					margin: 10rpx 0;
					font-size: 28rpx;
				}

				.list-item-r-m {
					font-size: 28rpx;
				}
			}
		}
	}

	.addUser {
		position: fixed;
		bottom: 40rpx;
		left: calc(50% - 200rpx);
		width: 400rpx;
		border-radius: 12rpx;
		box-shadow: 0 0 12rpx #ddd;
		background-color: #276aee;
		color: #fff;
		height: 60rpx;
		line-height: 60rpx;
		font-size: 33rpx;
		font-weight: bold;
		word-spacing: 6rpx;
		text-align: center;
	}
</style>